package ins.wink.service.impl;


import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


import ins.wink.entity.Goods;
import ins.wink.entity.GoodsStore;
import ins.wink.mapper.GoodsMapper;
import ins.wink.service.GoodsService;
/**
 * 存货ervice接口实现层
 */
@Service
@Transactional
public class GoodsServiceImpl implements GoodsService{
	//注册mapper层接口
	@Autowired
	private GoodsMapper goodsMapper;
	
	//查询所有
	@Override
	public List<GoodsStore> goodsStoreAlls() {
		List<GoodsStore> list = goodsMapper.goodsStoreAll();
		return list;
	}
	//查询通过条件
	@Override
	public List<GoodsStore> tjSelect(String nm, String goodname, String storeid) {
		//实例化一个新的map对象
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("nm", nm);
		map.put("goodname", goodname);
		map.put("storeid", storeid);
		List<GoodsStore> list = goodsMapper.tjSelect(map);
		return list;
	}
	
	//简记码查询一
	@Override
	public List<Goods> checkByStoreNms(String nm) {
		List<Goods>  goods = goodsMapper.checkByStoreNm(nm);
		return goods;
	}
	
	//查询商品剩余数量
	@Override
	public double goodsAmounts(String id) {
		double d = goodsMapper.goodsAmount(id);
		return d;
	}
	
	//已有物品编号进行修改
	@Override
	public int updateGoodss(Map<String, Object>map) {
		//执行入库修改
		int i = goodsMapper.updateGoods(map);
		return i;
	}
	//物品编号不存在进行添加
	@Override
	public int addGoods(Goods goods) {
		int i = goodsMapper.addGoods(goods);
		return i;
	}
	//根据id查询
	@Override
	public Goods selectGoodsByIds(String id) {
		Goods id2 = goodsMapper.selectGoodsById(id);
		return id2;
	}
	//出库修改
	@Override
	public int updateGoods(Map<String, Object> map) {
		int i = goodsMapper.updateGood(map);
		return i;
	}
	//删除商品
	@Override
	public int deleteGoodss(String id) {
		int i = goodsMapper.deleteGoods(id);
		return i;
	}

	
}
